package com.ehotting.edsta.mqbd.circuit.client.handler;


import com.ehotting.mqbd.api.bean.MQDataAble;
import com.ehotting.mqbd.api.enums.DirectionEnum;
import com.ehotting.mqbd.api.enums.MQDataPushModelEnum;
import com.ehotting.mqbd.api.enums.TopicEnum;
import com.ehotting.mqbd.api.bean.MqApplicationContext;
import com.ehotting.mqbd.core.logger.MqMsgLogger;
import com.ehotting.mqbd.core.mq.consumer.action.ConsumerResponseAction;
import com.ehotting.mqbd.core.manager.ModuleManager;
import com.ehotting.mqbd.core.sync.MqSyncFutureMapHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CircuitConsumerResponseAction extends ConsumerResponseAction {

    private static final Logger logger = LoggerFactory.getLogger(CircuitConsumerResponseAction.class);

    protected CircuitSendUserServiceAble circuitSendUserService;

    public CircuitConsumerResponseAction(MqSyncFutureMapHelper<MQDataAble> mqSyncFutureMapHelper,
                                    MqApplicationContext mqApplicationContext,
                                    TopicEnum topic,
                                    DirectionEnum direction,
                                    ModuleManager moduleManager, MqMsgLogger mqMsgLogger) {
        super(mqSyncFutureMapHelper, mqApplicationContext, topic, direction, moduleManager,mqMsgLogger);
    }

    public CircuitConsumerResponseAction(MqSyncFutureMapHelper<MQDataAble> mqSyncFutureMapHelper,
                                    MqApplicationContext mqApplicationContext,
                                    TopicEnum topic,
                                    DirectionEnum direction,
                                    String nodeIp,
                                    ModuleManager moduleManager, MqMsgLogger mqMsgLogger) {
        super(mqSyncFutureMapHelper, mqApplicationContext, topic, direction, nodeIp, moduleManager,mqMsgLogger);
    }

    @Override
    public void extInvoke(MQDataAble data) {
        if(data.getPushModel() != MQDataPushModelEnum.HTTP_PUSH){
            circuitSendUserService.sendToUser(data);
        }
    }

    public void setCircuitSendUserService(CircuitSendUserServiceAble circuitSendUserService) {
        this.circuitSendUserService = circuitSendUserService;
    }
}
